#if _MSC_VER
 #pragma once
#endif // _MSC_VER

#ifndef __HERZELEID_AUDIOSTREAMER_INCLUDED___
 #define __HERZELEID_AUDIOSTREAMER_INCLUDED___
 #include "HerzeleidMedia.hxx"
 #include "HerzeleidReaderWriter.hxx"

HerzeleidMediaNamespaceBegin class AudioStreamer
{
public:

	typedef HerzeleidUtilityNamespaceImpl::BasicReaderWriter Reader;
#ifdef HERZELEID_DESKTOP
	typedef std::unique_ptr<HerzeleidUtilityNamespaceImpl::BasicReaderWriter> ReaderPtr;
	typedef Platform::Array<Byte> ByteArray;
#else
	typedef HerzeleidUtilityNamespaceImpl::BasicReaderWriter^ ReaderPtr;
	typedef Platform::Array<Byte>^ ByteArray;
#endif

private:

	WaveFormat m_OutputWaveFormat; // .wav format
	ByteArray m_Data; // File buffer

	UInt32 m_uMaxStreamLength; // In bytes
	UInt32 m_uOffset; // In bytes 

public:

	AudioStreamer();
	// m_Data will be deallocated automatically.
	//~AudioStreamer(); 

	Void ReadNextMemoryChunk(
		_Outptr_ BytePtr pBuffer, _In_ UInt32 uDesiredBufferSize, 
		_Outptr_ UInt32Ptr pBufferSize
		);
	Void ReadAllMemory( 
		_Outptr_ BytePtr pBuffer, _In_ UInt32 uMaxBufferSize, 
		_Outptr_ UInt32Ptr pBufferSize 
		);
	Void Initialize( 
		_In_ LPCWSTR wszUrl 
		);
	Void Restart(
		);

	// Properties

	//ReaderPtr Reader; // Data binary reader. 
#ifdef HERZELEID_DESKTOP
	inline UInt32Const Offset() { return m_uOffset; }
	inline UInt32Const MaxStreamLength() { return m_Data.Length; }
	inline WaveFormatConstPtr WaveFormat() { return &m_OutputWaveFormat; }
#else
	inline UInt32Const Offset() { return m_uOffset; }
	inline UInt32Const MaxStreamLength() { return m_Data->Length; }
	inline WaveFormatConstPtr WaveFormat() { return &m_OutputWaveFormat; }
#endif

} HerzeleidMediaNamespaceEnd;

#endif // !HERZELEID_AUDIOSTREAMER_INCLUDED___
